#pragma once

#define ARRAY_COUNT(ARY)\
	(sizeof(ARY)/sizeof(ARY[0]))

#define FOREACH(TYPE, LIST, ITOR)\
	for(TYPE::iterator ITOR = LIST.begin(); ITOR != LIST.end(); ITOR++)

#define FORIDX(TYPE, IDX, END)\
	for(TYPE IDX = 0; IDX <= END; IDX++)

#define RSURE(exp)\
	if(!(exp)) return

#define RBSURE(exp)\
	if(!(exp)) return FALSE

#define RVSURE(exp, val)\
	if(!(exp)) return val

#define BPUSER __asm int 3

#define BPSURE(exp)\
	if(!(exp)) BPUSER

#define VARDEF(T, N)\
	static T& N(){\
	T g_##N; return g_##N;}

#define VARARY_BEG(T, N)\
	static T& N(){\
	T g_aValue[] ={

#define VARARY_END\
	} return g_aValue;}

#define MIN(a, b) \
	((a) < (b)? (a): (b))

#define MAX(a, b) \
	((a) > (b)? (a): (b))

#define HITU16(W)\
	(TU08)((TU16)(W)>>8)

#define LOTU16(W)\
	(TU08)((TU16)(W)&0xFF)

#define HITU32(DW)\
	(TU16)((TU32)(DW)>>16)

#define LOTU32(DW)\
	(TU16)(((TU32)(DW))&0xFFFF)

#define HITU64(QW)\
	(TU32)((TU64)(QW)>>32)

#define LOTU64(QW)\
	(TU32)((TU64)(QW)&0xFFFFFFFF)

#define ADDR_ASSIGN(ADDR, VAL)\
	if(ADDR) *(ADDR) = VAL







